package com.itheima.conllection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class Collectiontest01 {
    public static void main(String[] args) {
        Collection<Integer> collection=new ArrayList<>();
        collection.add(1);
        collection.add(3);
        collection.add(2);
//        System.out.println(collection);
//        method(collection);
       Iterator<Integer> it=collection.iterator();
       while (it.hasNext()){
           Integer next = it.next();
           if (next.equals(1)){
               it.remove();
           }
           System.out.println(next);
       }
        System.out.println(collection);
        System.out.println("--------------------------");
             for (int i = 0; i < collection.size(); i++) {
            System.out.println(i);
        }
//        System.out.println("--------------------------");
//        for (Integer integer : collection) {
//            System.out.println(integer);
//        }
    }

    private static void method(Collection<Integer> collection) {
        collection.removeIf((Integer i)->{
            return i==1;
        });
        System.out.println(collection);
        collection.remove(2);
        System.out.println(collection);
        System.out.println(collection.contains(2));
        System.out.println(collection.isEmpty());
    }
}
